package com.dolphin.apipassenger.service;

import com.dolphin.apipassenger.remote.ServicePriceClient;
import com.dolphin.common.dto.ResponseResult;
import com.dolphin.common.request.ForecastPriceDTO;
import com.dolphin.common.response.ForecastPriceResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ForecastPriceService {

    @Autowired
    ServicePriceClient servicePriceClient;

    /**
     * 根据出发地和目的地经纬度计算价格
     * @param depLongitude
     * @param depLatitude
     * @param destLongitude
     * @param destLatitude
     * @return
     */
    public ResponseResult forecastPrice(String depLongitude, String depLatitude, String destLongitude, String destLatitude,String cityCode,String vehicleType) {
        log.info("出发地经度：" + depLongitude);
        log.info("出发地纬度：" + depLatitude);
        log.info("目的地经度：" + destLongitude);
        log.info("目的地纬度：" + destLatitude);

        log.info("调用计价服务，计算价格.............................");
        ForecastPriceDTO foreCastDto = new ForecastPriceDTO();
        foreCastDto.setDepLongitude(depLongitude);
        foreCastDto.setDepLatitude(depLatitude);
        foreCastDto.setDestLongitude(destLongitude);
        foreCastDto.setDestLatitude(destLatitude);
        foreCastDto.setCityCode(cityCode);
        foreCastDto.setVehicleType(vehicleType);
        ResponseResult<ForecastPriceResponse> responseResult = servicePriceClient.forecastPrice(foreCastDto);
        ForecastPriceResponse forecastPriceResponse = responseResult.getData();

        return ResponseResult.success(forecastPriceResponse);
    }
}
